From: Carl Lerche Date: Tue, 6 May 2014 23:24:00 +0000 (-0700) Subject: Source list returns summaries X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~1085 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=937303398d86f75de54b7165616ce9787be6f68a;p=cargo.git Source list returns summaries --- diff --git a/src/cargo/core/mod.rs b/src/cargo/core/mod.rs index 5f1c7a92f..88a403c65 100644 --- a/src/cargo/core/mod.rs +++ b/src/cargo/core/mod.rs @@ -17,6 +17,10 @@ pub use self::package::{ PackageSet }; +pub use self::source::{ + Source +}; + pub use self::summary::{ Summary }; diff --git a/src/cargo/core/source.rs b/src/cargo/core/source.rs index 6132ce323..1e0de7415 100644 --- a/src/cargo/core/source.rs +++ b/src/cargo/core/source.rs @@ -1,12 +1,11 @@ -use core::{NameVer,Package}; +use core::{Summary,NameVer,Package}; use core::errors::CargoResult; -use std::fmt::Show; /** * A Source finds and downloads remote packages based on names and * versions. */ -pub trait Source : Show { +pub trait Source { /** * The update method performs any network operations required to * get the entire list of all names, versions and dependencies of @@ -20,7 +19,7 @@ pub trait Source : Show { * already been called and no additional network operations are * required. */ - fn list(&self) -> CargoResult>; + fn list(&self) -> CargoResult>; /** * The download method fetches the full package for each name and diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index c4b006931..28e763e84 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -18,10 +18,8 @@ use std::vec::Vec; use std::os; use util::config; use util::config::{all_configs,ConfigValue}; +use core::{PackageSet,Source,Dependency,NameVer}; use core::resolver::resolve; -use core::package::PackageSet; -use core::source::Source; -use core::dependency::Dependency; use sources::path::PathSource; use ops::cargo_rustc; use core::errors::{CargoError,CLIError,CLIResult,ToResult}; @@ -38,11 +36,14 @@ pub fn compile(manifest_path: &str) -> CLIResult<()> { }; let source = PathSource::new(paths); - let names = try!(source.list().to_result(|err| CLIError::new(format!("Unable to list packages from {}", source), Some(err.to_str()), 1))); - try!(source.download(names.as_slice()).to_result(|err| CLIError::new(format!("Unable to download packages from {}", source), Some(err.to_str()), 1))); + let summaries = try!(source.list().to_result(|err| CLIError::new(format!("Unable to list packages from {}", source), Some(err.to_str()), 1))); + let names: Vec = summaries.iter().map(|s| s.get_name_ver().clone()).collect(); - let deps: Vec = names.iter().map(|namever| { - Dependency::with_namever(namever) + // This does not need to happen + // try!(source.download(names.as_slice()).to_result(|err| CLIError::new(format!("Unable to download packages from {}", source), Some(err.to_str()), 1))); + + let deps: Vec = summaries.iter().map(|summary| { + Dependency::with_namever(summary.get_name_ver()) }).collect(); let packages = try!(source.get(names.as_slice()).to_result(|err| diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 0e69281f7..b73c5b54c 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -1,6 +1,6 @@ use std::fmt; use std::fmt::{Show,Formatter}; -use core::{NameVer,Package}; +use core::{NameVer,Package,Summary}; use core::source::Source; use core::errors::{CargoResult,CargoCLIError,ToResult}; use cargo_read_manifest = ops::cargo_read_manifest::read_manifest; @@ -24,10 +24,10 @@ impl Show for PathSource { impl Source for PathSource { fn update(&self) -> CargoResult<()> { Ok(()) } - fn list(&self) -> CargoResult> { + fn list(&self) -> CargoResult> { Ok(self.paths.iter().filter_map(|path| { match read_manifest(path) { - Ok(ref pkg) => Some(pkg.get_summary().get_name_ver().clone()), + Ok(ref pkg) => Some(pkg.get_summary().clone()), Err(_) => None } }).collect())